package com.vinder.api.util;

import redis.clients.jedis.Jedis;


public class JedisUtil {
    private static Jedis jedis;

    static {
        jedis = new Jedis("47.110.146.167", 6380);
        jedis.auth("123456");
        jedis.select(15);
    }

    //新增
    public static void addString(String key, String val) {
        jedis.set(key, val);
    }

    public static void addString(String key, String val, long seconds) {
        jedis.setex(key, (int) seconds, val);
    }

    public static void addSet(String key, String val) {
        jedis.sadd(key, val);
    }

    //校验
    public static boolean checkKey(String... key) {
        return jedis.exists(key) > 0;
    }

    public static boolean checkSet(String key, String val) {
        return jedis.sismember(key, val);
    }

    //获取
    public static String getString(String key) {
        return jedis.get(key);
    }

    //删除
    public static void delKeys(String... keys) {
        jedis.del(keys);
    }

}
